Pascal Programming: An Introduction
Copyright ⌐ 1998 Xpro

Document Courtesy Of The Immortal Descendants (NOTE: This essay is outdated, and is no longer updated or supported)
	What is Pascal?  In the following text you will find out
how Pascal programs work and functions of different sorts.  I recommend
getting Turbo Pascal v.7.0, I have no idea where to find it, whether you 
can find it at stores, all i know and say is that my teacher gave it to
me and if you really wanna start learning it, contact me and i'll zip and 
send.

	First a pascal program is made up of a PROGRAM HEADING and a 
MAIN PROGRAM BLOCK, which accomplishes what your trying to do in your
program.  Within the MAIN PROGRAM BLOCK there is a code with the keywords
of, Begin and end.  Take a look at this illustration to display my point:

PROGRAM SAMPLE;
BEGIN
WRITELN('THIS IS A SAMPLE');
END.

	As you can see the program is named in the program heading, and 
that name is SAMPLE. The MAIN PROGRAM BLOCK is also included, which 
accomplishes what I'm trying to do in my program.  As you can see there
is only one line within the MAIN PROGRAM BLOCK, but there can be many 
lines.  I will only introduce you to a few simple commands in this text.

	Ok the program illustrated above will do nothing right now.  To 
have it actually do something you must list the USES the program will use 
to diplay the output of the program.  For right now I'll introduce you 
to CRT(screen) an PRINTER(printer).  Take a look at this other 
illustration to display my point:

PROGRAM SAMPLE;
USES CRT, PRINTER;
BEGIN
WRITELN('THIS IS A SAMPLE');
END.

	The program name is SAMPLE, the output of the program will
be diplayed on the screen and printer (something to be touched on later).
The program has been started with a BEGIN followed with a command then 
followed with an END.

	If you take notice at the end of each line it ends with an 
semi-colon.  This is a must, all lines with an exception with some 
commands, need a semi-colon at the end. oK, lemme guide you through the 
program about and explain what each line does.  By now you should know the 
PROGRAM HEADING statement, it names the program to whatever you want it.  
Second the uses of the program is diplayed with the CRT and PRINTER. Third 
the program is began with a BEGIN and then followed with WRITELN. Ok what 
WRITELN actually does is print something out on the screen what i mean by 
print is like make that section enclosed with ' to appear on the screen when 
the program is ran. Then finally the program is finished with and END. I'd 
like to point out on some cases when the END command is being used it can be 
end with an semi-colon.  Just remember this the last end ALWAYS has an 
period followed.

	Okay now that you can understand a program of that calibre I want 
you to interpet the following program.  Try to tell yourself what the name 
of the program is, what the uses are, and what gonna happen between the 
MAIN PROGRAM BLOCK.  Try not to look at the answer unless you are still 
absolutly clueless about the program.

PROGRAM AGE;
USES CRT;
BEGIN
WRITELN('HELLO I AM 16 YEARS OLD');
END.

	Now that you've had time to look at the program about the Program 
names is located in the Program heading, the program name is, AGE.  The uses 
is listed, and the uses is, CRT(screen).  The program now begins and is 
followed with an WRITELN which can only mean it's gonna display whatever is 
present between the ' which is, HELLO I AM 16 YEARS OLD. Then the program is 
ended off.

	I'm pretty sure we got the easy stuff down so now lets go onto 
variables.  First let me try to define what a variable is.  A variable is a 
word that is used in replace of something else.  Lets take a look at some 
source and I'll explain what each line does.

PROGRAM AGE;
USES CRT;

VAR
YOURAGE:INTEGER;
YOURAGEYEARS:INTEGER;
ANSWER:CHAR;

BEGIN
WRITELN('PLESE TYPE IN YOUR AGE');
READLN(YOURAGE);
YOURAGEYEARS:=2+YOURAGE;
YOURAGE:=YOURAGEYEARS+1;
WRITELN('IN THE YEAR 2000 YOU WILL BE',YOURAGEYEARS:3,'OR':3,YOURAGE:3);
END.

	First, the program is named in program heading which is AGE.  Next 
the uses are listed which are CRT(screen).  Now, you're gonna have variables, 
so you must have a section telling the program that the following under it is 
gonna be followed by variables, and we do that with VAR.  As you can see 
there are three lines under var section, meaning there are three variables.  
You shouldn't really base on how many lines there are theres gonna be an equal 
ammount of variables.  
	The first variable is YOURAGE as you can see there is a colon and word 
saying INTEGER, what does integer mean?  Well, basically, integer is a whole 
number and it's telling the program that that variable(YOURAGE) is gonna be set 
as INTEGER(whole number).  Why a whole number?  We'll get into it in awhile. 
	The next variable is YOURAGEYEARS, which is also equal to an 
INTEGER(whole number).  Next is an ANSWER which is a CHAR, short for Character, 
telling the program that the following variable is gonna be set as character.  
	Now we begin the program, with a BEGIN.  Under BEGIN, REPEAT is listed, 
why? Because it's pointing out when it loops it will start on that BLOCK 
PROGRAM (note: There can be several blockprograms in a main block program.)
	Under REPEAT is WRITELN command you should already know what that 
command does and that is, make that section between the '''s appear on the 
screen when it's ran.  Next is the READLN command.  Now, what this does is 
prompt the user for input, that input will be set as the variable that is 
between the ()'s which is YOURAGE.  This is why i chose INTEGER for the 
variable, because if I ask for someone's age, it's obviously gonna be a whole 
number.  Tell me how many ppl respond with an "I am 15.5 years old", now lets 
say that were to actually happen, then we'd have to replace the INTEGER with a 
REAL statement.  What real is, is a number that is not a whole number, in 
other words, it has decimals.  
	Next we put the variable to equal something, that something is 
2+YOURAGE, how would you figure out what this is?  Well, what that does is add 
two to whatever the user typed in, so lets say he typed in 16, it would set 
YOURAGEYEARS to be 2+YOURAGE(16) which is 18.  
	Next it re-sets the variable YOURAGE to equal something different, 
that is YOURAGEYEARS+1, the variable YOURAGEYEARS was set to 18 which was what
the user entered.  Now, since YOURAGE is YOURAGEYEARS+1, we would add 1 to what 
YOURAGEYEARS equaled.  
	Next it time to write out on the screen our results.  Again you see the 
command WRITELN which prints out what ever is between the '''s.  In this case it 
would write out "IN THE YEAR 2000 YOU WILL BE".  Also, as you can see, we want 
the variable to be written along with the msg between the '', so to show to the 
program that we are gonna going to discontinue '', we put a comma(,) and follow 
it with the desired variable.  Then we must 
show we are going to continue with '', so we must put another comma(,) and contiue 
with the ''.  I know you are probably wondering what the :3 is for.  Well, what 
that does is tell the program that the variable or '' is gonna be 3 spaces away 
from where the previous line ended.  
	I know i'm confusing the fuck out of you so again here is an 
illustration to display my point:

Source Code:
WRITELN('In the year 2000 you will be',YOURAGEYEARS:3,'or':3,YOURAGE:3);

OutPut(if the user typed in 16)

In the year 2000 you will be 18 or 19

What if I didn't put the :3 ?

Source Code:
WRITELN('In the year 2000 you will be',YOURAGEYEARS,'or',YOURAGE);

OutPut(if the user typed in 16)

in the year 2000 you will be18or19

Yes that is correct, with no spaces between the variable's equal.

	Well, hopefully you can understand the text. This is my first txt i've 
ever written so hey, give me credit and alittle applause.  Welp, this is the 
ending of lesson 1, lesson 2 will come shortly.  Next lesson we will learn the 
IF THEN ELSE commands and learn Loops, Bye now :D

-Xpro-